// ========================================================
// Des：
// Autor：Mr.H 
// CreateTime：2024/04/06 21:45:48
// 版 本：v 1.0
// ========================================================
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WeaponObj : MonoBehaviour
{
    public GameObject bullet;
    //外部决定有几个发射位置
    public Transform[] shootPos;

    //武器拥有者
    public TankBaseObj fatherObj;

    /// <summary>
    /// 设置拥有者
    /// </summary>
    public void SetFather(TankBaseObj obj)
    {
        fatherObj = obj;
    }
    public void Fire()
    {
        for (var i = 0; i < shootPos.Length; i++)
        {
            //创建子弹预设体
            GameObject obj = Instantiate(bullet, shootPos[i].position, shootPos[i].rotation);
            //控制子弹做什么
            BulletObj bulletObj = obj.GetComponent<BulletObj>();
            Debug.Log($"子弹：{bulletObj}");
            bulletObj.SetFather(fatherObj);
        }
    }
}
